<!--各品牌商品交易统计-->
<template>
  <div>

    <el-table
      height="250"
      :data="tableData"
      style="width: 100%;font-size: 15px"
      :header-cell-style="{background:'#eef1f6',color:'#606266'}"
    >

      <el-table-column
        prop="tmName"
        label="品牌名称"
      >
        <template slot-scope="scope">
          <div v-html="scope.row.tmName"></div>
        </template>
      </el-table-column>
      <el-table-column
        prop="orderCount"
        label="订单数"
        width="150">
      </el-table-column>
      <el-table-column
        prop="orderUserCount"
        label="订单人数" width="150">
      </el-table-column>
      <el-table-column
        prop="orderRefundCount"
        label="退单数" width="150">
      </el-table-column>
      <el-table-column
        prop="orderRefundUserCount"
        label="退单人数" width="150">
      </el-table-column>

    </el-table>
    <!-- 分页组件 -->
    <el-pagination
      :current-page="page"
      :total="total"
      :page-size="limit"
      :page-sizes="[5, 10, 20, 30, 40, 50, 100]"
      style="padding: 30px 0; text-align: center;"
      layout="sizes, prev, pager, next, jumper, ->, total, slot"
      @current-change="fetchData"
      @size-change="changeSize"
    />
  </div>
</template>

<script>
import api from "@/api/statistics/goods/goods";

export default {

  // 生命周期函数：内存准备完毕，页面渲染成功
  mounted() {
    this.init()
  },

  data() {
    return {
      itemName: "",
      date: "",
      total: 0, // 数据库中的总记录数
      page: 1, // 默认页码
      limit: 10, // 每页记录数
      tableData: [],
      searchObj: {
        recentDays: this.$parent.recentDays,
        dt: this.$parent.curDate
      }
    }
  },
  methods: {
    init() {
      this.searchObj.recentDays = this.$parent.recentDays
      this.searchObj.dt = this.$parent.curDate
      this.fetchData(this.page)
    },
// 当页码发生改变的时候
    changeSize(size) {
      console.log(size)
      this.limit = size
      this.fetchData(1)
    },

    // 加载banner列表数据
    fetchData(page = 1) {
      console.log('翻页。。。' + page)
      // 异步获取远程数据（ajax）
      this.page = page
      /**
       * 各渠道流量统计接口
       */
      api.getTmTradeStats(this.page, this.limit, this.searchObj)
        .then((response) => {
          this.tableData = response.data.records
          // console.log("========tableData"+this.tableData)
          this.total = response.data.total
        })
        .catch((response) => {
          console.log("失败" + response)
        })
    }
  }
}
</script>

<style>
em {
  font-style: normal;
  color: red;
}
</style>
